package com.qifenqian.turbot.module.adapter.marketing

import android.view.View
import com.bumptech.glide.Glide
import com.bumptech.glide.load.resource.bitmap.RoundedCorners
import com.bumptech.glide.request.RequestOptions
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.BaseViewHolder
import com.qifenqian.turbot.R
import kotlinx.android.synthetic.main.item_marketing.view.*
import org.jetbrains.anko.dip

/**
 * @author H
 * @createTime 2019/1/3 09:56
 * @description
 * @see
 * @since
 */
open class MarketingRvAdapterBase(list: List<String>) : BaseQuickAdapter<String, BaseViewHolder>(R.layout.item_marketing, list) {

    override fun convert(helper: BaseViewHolder?, item: String?) {
        val view = helper!!.itemView
        view.tv_item_marketing_title.text = item
        view.tv_item_marketing_note.text = item
        view.tv_item_marketing_tag.visibility = if (1 == 1) View.VISIBLE else View.INVISIBLE
        view.tv_item_marketing_tag.text = if (1 == 1) "首页展示" else "强烈推荐"
        view.tv_item_marketing_tag.setBackgroundResource(R.drawable.bg_rectangle_red)
        view.tv_item_marketing_switch.text = if (1 == 1) "已启用" else "未开启"
        val options = RequestOptions.bitmapTransform(RoundedCorners(mContext.dip(6)))
        Glide.with(mContext)
                .load("https://ss0.baidu.com/6ONWsjip0QIZ8tyhnq/it/u=1989353433,2279935566&fm=58&bpow=512&bpoh=512")
                .apply(options)
                .into(view.iv_item_marketing_background)
    }
}
